<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div id="div1">
    <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <p style="color: #0070C0;text-align: center;font-size: large;font-weight: bold;">报价揭示列表</p><br>
                    <div class="layui-card-body " style="text-align: center">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-inline">
                                询价书名称：
                                <div class="layui-input-inline">
                                    <input type="text" name="enquireName" id="enquireName" autocomplete="off"  placeholder="询价书名称" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <!--<button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>-->
                                <button class="layui-btn" data-type="reload" id="search">搜索</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-table layui-form" lay-filter="test" id="test"></table>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<div id="div2">
    <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <!--<table class="layui-table layui-form" id="test"></table>-->
                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%"
                               bgColor=#336699 borderColorLight=#006699 border=0>
                            <TBODY>
                            <TR>
                                <TD>
                                    <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>
                                        <TBODY>
                                        <TR bgColor=#ffffff>
                                            <TD align=middle width="100%" bgColor=#ffffff colSpan=20
                                                height=22>
                                                <H2 style="color:#0070c0 "><B>询价书明细</B></H2> <A
                                                    onclick="window.open('../help/Help.asp?Value=询价书明细信息','child','status=NO,scrollbars=yes,toolbar=no,menubar=no,location=no,left=200,top=100,width=700,height=400')"
                                                    href="javascript:void(null)"></A>
                                                </TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%" >询价书编号</TD>
                                            <TD class=t2 noWrap id="enquireNum"></TD>
                                            <TD noWrap width="20%">询价书名称</TD>
                                            <TD class=t2 noWrap id="enquireName2"></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">单位</TD>
                                            <TD class=t2 noWrap id="company"></TD>
                                            <TD noWrap width="20%">联系人</TD>
                                            <TD class=t2 noWrap id="linkman"></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">联系地址</TD>
                                            <TD class=t2 noWrap id="address"></TD>
                                            <TD noWrap width="20%">联系电话</TD>
                                            <TD class=t2 noWrap id="phone"></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">联系传真</TD>
                                            <TD class=t2 noWrap id="fax"></TD>
                                            <TD noWrap width="20%">邮编</TD>
                                            <TD class=t2 noWrap id="zip"></TD></TR>
                                        <TR class=t1>
                                            <TD noWrap width="20%">Email</TD>
                                            <TD class=t2 noWrap id="email"></TD>
                                            <TD noWrap width="20%">报价截止时间</TD>
                                            <TD class=t2 noWrap id="endDate">
                                            </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
                        <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=0 width="100%" bgColor=#ffffff
                               borderColorLight=#ffffff border=0>
                            <TBODY>
                            <TR>
                                <TD>
                                    <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%"
                                           border=0><B>我公司欲采购下述物资，如贵单位有兴趣，可参与网上报价。详细物资情况如下：</B>
                                        <TBODY></TBODY></TABLE></TD></TR></TBODY></TABLE>
                        </table></td></tr></table>

                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0  id="tableEnquire"   width="100%"  bgColor=#336699 borderColorLight=#006699 border=0>

                        </table>

                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0     width="100%"  bgColor=#336699 borderColorLight=#006699 border=0>
                            <tr>
                                <td>
                                    <table cellpadding="3" cellspacing="1" border="0" width="100%">

                                        <tr class="t2">
                                            <td nowrap>报价有效期</td>
                                            <td id="startDate">
                                                <span style="width:100%"></span>
                                            </td>
                                        </tr>
                                        <tr class="t2">
                                            <td nowrap>询价说明</td>
                                            <td style="width:100%"><textarea name="textarea" id="remark" rows="4" readonly style="width:100%"></textarea>&nbsp;</td>
                                        </tr>
                                    </table></td></tr></table>

                        </form>
                        <script Language="JavaScript" src="js/pub_Calendar.js"></script>
                        <script language="javascript">
                            function QuotePrint(p_QuoteNo)
                            {
                                window.open("Quote_Print.ASP?QuoteNo="+p_QuoteNo,"","toolbar=0,resizable=yes,location=0,status=0,menubar=1,scrollbars=1,width=800,height=600,left=0,top=0");
                            }
                        </script>
                        <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%"
                               bgColor=#336699 borderColorLight=#006699 border=0>
                            <TBODY>
                            <TR>
                                <TD>
                                    <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
                                        <TBODY>
                                        </TBODY></TABLE></TD></TR></TBODY></TABLE><BR></FORM>

                        <CENTER>

                            <BR>&nbsp;<INPUT id=button1 onclick="location.href='/contractmanager/jieshilist.html'" type=button value=返回 name=button1>
                        </CENTER>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<div id="div3">
    <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <!--<table class="layui-table layui-form" id="test"></table>-->
                        <FORM name=form action=Apply_Save.asp method=post>
                            <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0
                                   width="100%" bgColor=#336699 borderColorLight=#006699 border=0>
                                <TBODY>
                                <TR>
                                    <TD>
                                        <TABLE class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>
                                            <TBODY>
                                            <TR bgColor=#ffffff>
                                                <TD align=middle width="100%" bgColor=#ffffff colSpan=20
                                                    height=22>
                                                    <H2 style="color: #0070c0"><B>编制合同申请</B></H2>
                                                </TD>
                                            </TR>
                                            <TR class=t1>
                                                <TD width="20%">询价书名称：</TD>
                                                <TD class=t2 width="30%">
                                                    <A href="javascript:alert('对应询价书详细')" id="enquireName3"></A>
                                                </TD>
                                                <TD width="20%">报价份数：</TD>
                                                <TD class=t2 width="30%" id="statQuote"></TD>
                                            </TR>
                                            <TR class=t1>
                                                <TD width="20%">最高报价（元）：</TD>
                                                <TD class=t2 width="30%" id="topQuote"></TD>
                                                <TD width="20%">最低报价（元）：</TD>
                                                <TD class=t2 width="30%" id="lowQuote"></TD>
                                            </TR>
                                            </TBODY>
                                        </TABLE>
                                    </TD>
                                </TR>
                                </TBODY>
                            </TABLE>

                            <TABLE class="layui-table layui-form" style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0
                                   width="100%" bgColor=#336699 borderColorLight=#006699 border=0>
                                <TBODY>
                                <TR>
                                    <table id="tableContract" class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>

                                    </table>
                                    <TD>
                                        <TABLE  class="layui-table layui-form" cellSpacing=1 cellPadding=3 width="100%" border=0>
                                            <TBODY >
                                            <TR class=t1>
                                                <TD align=middle>总金额（元）</TD>
                                                <TD colSpan=9>
                                                    <INPUT readOnly size=10 value=5001 name=p_total id="sumPrice">
                                                </TD>
                                            </TR>
                                            <TR class=t1>
                                                <TD align=middle>备注</TD>
                                                <TD colSpan=9>
                                                    <INPUT size=80 name=mark id="remark2">
                                                </TD>
                                            </TR>
                                            </TBODY>
                                        </TABLE>
                                    </TD>
                                </TR>
                                </TBODY>
                            </TABLE>

                                <BR>
                            <div style="text-align: center">
                                <INPUT onclick="QD()" type=button value=确定 name=button1>
                                <INPUT onclick="location.href='/contractmanager/jieshilist.html'" type=button value=返回 name=button1>
                            </div>

                        </FORM>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="EnqId">
<input type="hidden" id="EnqName">
</body>
<script id="button" type="text/html">
    <a class="layui-btn layui-btn-xs" lay-event="open">打开</a>
    <a class="layui-btn layui-btn-xs" lay-event="shenhe">合同编制</a>
</script>
<script>
    layui.use('table', function(){
        $("#div2").hide();
        $("#div3").hide();
        var table = layui.table;
        table.render({
            elem: '#test'  //html中渲染table的id
            , url: '/Enquire/all1'   //后台获取数据集合的地址
            , cellMinWidth: 80
            , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                //,curr: 5 //设定初始在第 5 页
                , groups: 1 //只显示 1 个连续页码
                , first: false//不显示首页
                , last: false //不显示尾页

            }, cols: [
                [
                    //表单显示的title以及返回的需要显示的数据，field值与获取集合中的类的字段名一致。
                    {field: 'id', title: '序号', align: 'center',width:80},
                    {field: 'enquireNum', title: '揭示时间', hide:'true' , align: 'center'},
                    {field: 'enquireName', title: '询价书名称',toolbar:'#link', align: 'center',width: 150},
                    {field: 'startDate', title: '揭示时间', align: 'center'},
                    { title: '操作', toolbar: "#button",align:'center', width:170}
                ]
            ],id:'tableAll'
        });
        table.on('tool(test)',function (obj) {
            let data = obj.data;
            if(obj.event === "open" || obj.event === "linkE"){
                $("#div1").hide();
                $("#div3").hide();
                $("#div2").show();
                //let enquireNum = data.enquireNum;
                $.ajax({
                    url:'/Enquire/findById',
                    data:{"enquireNum":data.enquireNum},
                    type:'post',
                    success:function (result) {
                        $("#enquireNum").html(result.enquireNum);
                        $("#enquireName2").html(result.enquireName);
                        $("#company").html(result.company);
                        $("#linkman").html(result.linkman);
                        $("#address").html(result.address);
                        $("#phone").html(result.phone);
                        $("#fax").html(result.fax);
                        $("#zip").html(result.zip);
                        $("#email").html(result.email);
                        $("#endDate").html(result.endDate);
                        var orders=result.stock.orders;
                        for(var i=0;i<orders.length;i++){
                            $("#tableEnquire").append(
                                "<tr>\n" +
                                "                                <td>\n" +
                                "                                    <TABLE class=\"layui-table layui-form\" cellSpacing=1 cellPadding=3 width=\"100%\" border=0>\n" +
                                "                                        <TBODY>\n" +
                                "                                        <TR class=t1>\n" +
                                "                                            <TD noWrap align=middle>物资编码</TD>\n" +
                                "                                            <TD noWrap align=middle>物资名称</TD>\n" +
                                "                                            <TD noWrap align=middle>数量</TD>\n" +
                                "                                            <TD noWrap align=middle>计量<BR>单位</TD>\n" +
                                "                                            <TD noWrap align=middle>交货期</TD>\n" +
                                "                                            <TD noWrap align=middle>协议价格<BR>（元）</TD>\n" +
                                "                                            <TD noWrap align=middle>预算总金额<BR>（元）</TD>\n" +
                                "                                            <TD noWrap align=middle>计划价<BR>（元/不含税）</TD></TR>\n" +
                                "                                        <TR class=t2>\n" +
                                "                                            <TD>"+orders[i].materialCode+"<BR></TD>\n" +
                                "                                            <TD>"+orders[i].materialName+"<BR></TD>\n" +
                                "                                            <TD align=right>"+orders[i].amount+"<BR></TD>\n" +
                                "                                            <TD>"+orders[i].measureUnit+"<BR></TD>\n" +
                                "                                            <TD>"+orders[i].startDate+"<BR></TD>\n" +
                                "                                            <TD noWrap align=middle><A\n" +
                                "                                                    ></A><BR></TD>\n" +
                                "                                            <TD>"+(orders[i].unitPrice*orders[i].amount)+"<BR></TD>\n" +
                                "                                            <TD>"+orders[i].unitPrice+"<BR></TD></TR>\n" +
                                "                                        \n" +
                                "                                        </TBODY>\n" +
                                "                                    </TABLE>\n" +
                                "                                </td>\n" +
                                "                            </tr>"
                            )
                        }
                    }
                })
            }
            else if(obj.event === "shenhe"){
                $("#div1").hide();
                $("#div2").hide();
                $("#div3").show();
                let id = data["id"];
                $.ajax({
                    url:'/contractmanager/SelByEnquireId',
                    data:{"id":id},
                    type:'post',
                    success:function (result) {
                        $("#EnqId").val(result.id);
                        $("#EnqName").val(result.enquireName);
                        $("#enquireName3").html(result.enquireName);
                        $.ajax({
                            url:'/contractmanager/SelQuoByEnquireId',
                            data:{"Num":result.enquireNum},
                            type:'post',
                            success:function (result1) {
                                $("#statQuote").html(result1.statQuote);
                                $("#lowQuote").html(result1.lowQuote);
                                $("#topQuote").html(result1.topQuote);
                                $("#sumPrice").val(result1.allSumPrice);
                                $.ajax({
                                    url:'/contractmanager/SelOrdersByEnqId',
                                    data:{"id":result.id},
                                    type:'post',
                                    success:function (result2) {
                                        for (let i=0;i<result2.length;i++) {
                                            $.ajax({
                                                url:'/contractmanager/SelQuoByOrderId',
                                                data:{
                                                    "id":result2[i].id,
                                                    "Num":result.enquireNum
                                                },
                                                type:'post',
                                                success:function (result3) {
                                                    let Str="";
                                                    for (let result3Element of result3) {

                                                       Str+= "                                            <TR class=t2>\n" +
                                                        "                                                <TD style='text-align: center' width=\"20%\">"+result3Element.supplierId+"<BR></TD>\n" +
                                                        "                                                <TD align=right>"+result3Element.amount+"<BR></TD>\n" +
                                                        "                                                <TD align=right>"+result3Element.unitPrice+"<BR></TD>\n" +
                                                        "                                                <TD style='text-align: center'  align=right>"+result3Element.mixPrice+"<BR></TD>\n" +
                                                        "                                                <TD style='text-align: center'  align=right>"+result3Element.otherPrice+"<BR></TD>\n" +
                                                        "                                                <TD style='text-align: center'  align=right>"+result3Element.totalPrice+"<BR></TD>\n" +
                                                        "                                                <TD style='text-align: center' >"+result3Element.startDate+"<BR></TD>\n" +
                                                        "                                                <TD style='text-align: center' >"+result3Element.endDate+"<BR></TD>\n" +
                                                        "                                            </TR>"
                                                    }
                                                    $("#tableContract").append(
                                                        "<TR class=T1>\n" +
                                                        "                                                <TD noWrap align=middle colSpan=9>\n" +
                                                        "                                                    物资\n" +
                                                        "                                                    <B color=red>"+(Number(i)+1)+" &nbsp;\n" +
                                                        "                                                    </B><A href=\"javascript:alert('对应需求计划书详细')\">"+result2[i].materialName+"</A>\n" +
                                                        "                                                    "+result2[i].amount+"\n" +
                                                        "                                                    <B>计划价（元/不含税）</B>："+result2[i].unitPrice+"\n" +
                                                        "                                                    <BR>\n" +
                                                        "                                                    <A onclick='XuanZe("+result2[i].id+")' href=\"javascript:void(0);\"><FONT\n" +
                                                        "                                                            color=red><U>请为该物资选择供应商</U> </FONT> </A><A\n" +
                                                        "                                                        href=\"javascript:alert('对应报价书详细')\"> 报价明细信息</A>&nbsp;&nbsp;\n" +
                                                        "                                                </TD>\n" +
                                                        "                                            </TR>\n" +
                                                        "                                            <TR class=t1>\n" +
                                                        "                                                <TD noWrap align=middle width=\"20%\">供应商编号</TD>\n" +
                                                        "                                                <TD noWrap align=middle>数量</TD>\n" +
                                                        "                                                <TD noWrap align=middle>单价<BR>（元/含税）</TD>\n" +
                                                        "                                                <TD noWrap align=middle>运杂费<BR>（元）</TD>\n" +
                                                        "                                                <TD noWrap align=middle>其它费用<BR>（元）</TD>\n" +
                                                        "                                                <TD noWrap align=middle>总计<BR>（元）</TD>\n" +
                                                        "                                                <TD noWrap align=middle>开始<BR>交货期</TD>\n" +
                                                        "                                                <TD noWrap align=middle>结束<BR>交货期</TD>\n" +
                                                        "                                            </TR>\n"+Str
                                                    )
                                                }
                                            })
                                        }
                                    }
                                })
                            }
                        })
                    }
                })
            }
        })
        $('#search').on('click', function(){
            table.reload('tableAll', {
                method : 'get',
                where : {
                    enquireName : $.trim($('#enquireName').val()),
                },
                page : {
                    curr : 1
                }
            });
            return false;
        });
    });
    function XuanZe(id){
        var StS="";
        var name="";
        $.ajax({
            url:'/contractmanager/SelOrdById',
            data:{
                "id":id,
            },
            type:'post',
            success:function (result1) {
                $.ajax({
                    url:'/contractmanager/SelSupByQuo',
                    data:{
                        "id":id,
                    },
                    type:'post',
                    success:function (result) {
                        for (let result3Element of result) {
                            StS+='      <tr>\n' +
                                '        <td style="text-align: center"><input style="display: block;margin-left: 35px" name="read" type="radio" value="'+result3Element.id+'"/></td>\n' +
                                '        <td style="text-align: center">'+result3Element.company+'</td>\n' +
                                '        <td style="text-align: center">'+result3Element.kind+'</td>\n' +
                                '        <td style="text-align: center">'+result3Element.contact+'</td>\n' +
                                '        <td style="text-align: center">'+result3Element.email+'</td>\n' +
                                '      </tr>\n'
                        }
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['620px', '340px'], //宽高
                            content: '<div class="layui-form" style="text-align: center">\n' +
                                '<b style="font-size: 20px;color: #0070c0">为 '+result1.materialName+' 选择供应商</b>  <table class="layui-table">\n' +
                                '    <colgroup>\n' +
                                '      <col width="30">\n' +
                                '      <col width="150">\n' +
                                '      <col width="200">\n' +
                                '      <col>\n' +
                                '    </colgroup>\n' +
                                '    <thead>\n' +
                                '      <tr>\n' +
                                '        <th style="text-align: center">选择</th>\n' +
                                '        <th style="text-align: center">公司名称</th>\n' +
                                '        <th style="text-align: center">公司性质</th>\n' +
                                '        <th style="text-align: center">联系人</th>\n' +
                                '        <th style="text-align: center">email</th>\n' +
                                '      </tr> \n' +
                                '    </thead>\n' +
                                '    <tbody>\n' +StS+
                                '    </tbody>\n' +
                                '  </table>\n' +
                                '<button class="layui-btn" onclick="XzQd('+id+')">确定</button></div>'
                        });
                    }
                })
            }
        })

    }
    function XzQd(id){
        var SupId=$("input[name='read']:checked").val();
        $.ajax({
            url:'/contractmanager/QueDing',
            data:{
                "orderId":id,
                "suppId":SupId,
                "enquireId":$("#EnqId").val()
            },
            type:'post',
            success:function (result) {
                alert("选择成功！")
                layer.closeAll();
            }
        })
    }
    function QD(){
        var statQuote=$("#statQuote").html();
        var topQuote=$("#topQuote").html();
        var lowQuote=$("#lowQuote").html();
        var allSumPrice=$("#sumPrice").val();
        var remark=$("#remark2").val();
        var code=$("#EnqName").val();
        var enquireId=$("#EnqId").val();
        var enquireName=$("#enquireName3").html();
        $.ajax({
            url:'/contractmanager/QueDing',
            data:{
                "statQuote":statQuote,
                "topQuote":topQuote,
                "lowQuote":lowQuote,
                "allSumPrice":allSumPrice,
                "remark":remark,
                "code":code,
                "enquireId":enquireId,
                "enquireName":enquireName
            },
            type:'post',
            success:function (result) {
                alert("编制成功！")
                location.reload();
            }
        })
    }
</script>
<script id="link" type="text/html">
    <a lay-event="linkE" class="layui-table-link" target="_self">{{ d.enquireName }}</a>
</script>

</html>